package com.wanbangee.marksystem.service.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.wanbangee.marksystem.dao.SScoreDao;
import com.wanbangee.marksystem.entities.MExamMarker;
import com.wanbangee.marksystem.service.ProgressCheckService;
import com.wanbangee.marksystem.service.score.SettingScoreService;

@Service
public class ProgressCheckServiceImp implements ProgressCheckService {
	
	@Autowired
	private SScoreDao sScoreDao;
	

	
	@Override
	public Integer ExamResolve(Integer examId, Integer examSubId, Integer oldMarkerId,
			Integer topicCount, Integer topicNo, Integer newMarkerId,SettingScoreService settingScoreService) {
		
		//1. 更新阅卷组表
		// 把旧的的数量相减一下
		// 把新的的数量添加一下
		int result1 = settingScoreService.updateMExamMarkerCount(oldMarkerId, topicCount, newMarkerId);
		//2. 更新阅卷表
		// 查询新的阅卷老师 tea_id,tea_id1,tea_id2
		if(result1 == 0) return 0;
		MExamMarker mExamMarker = settingScoreService.selectMExamMarkerByMarkerIdOnResolver(newMarkerId);
		//	要把还未打分的卷子的 markerid,teaId,tea_id1,tea_id2 修改为新的阅卷老师
		int result2 = sScoreDao.updateSScoreByExamIdAndExamSubIdAndTopicNoAndMarkerId(examId, examSubId, oldMarkerId, mExamMarker.getTeaId(), mExamMarker.getTeaId1(), mExamMarker.getTeaId2(), topicNo, newMarkerId, topicCount, mExamMarker.getScoreType());
		return result2>0?1:0;
	}



	@Override
	public List<MExamMarker> selectRepeatList(Integer teaId, Integer schId) {
		// 通过 teaId 和 schId 查询到  exam_id 和 exam_sub_id，并且能获得 topic_no
		
		// 根据获取到的 exam_id 和 exam_sub_id 去找到阅卷表，在阅卷表中，根据 is_repeat = 1 和 tea_id = teaId
		// 根据获取到的 exam_id 和 exam_sub_id 去找到阅卷表，在阅卷表中，根据 is_repeat = 1 和 tea_id = teaId、然后再根据题号分组，然后考场和科目可以通过 exam_id 和 exam_sub_id 获得
		return null;
	}

}
